<div class="page-search-bar">
	<div class="widget-header">
		<div class="align-left">
			<%= simple_form_for(new_contract_path, :method => 'get') do |f| %>
			供方：
			<select class="select optional" css="" id="contract_sellers" name="contract[sellers]" >
				<option value=""></option>
				<% Supplier.all.each do |s| %>
				<option value="<%= s.id %>"><%= s.name %></option>
				<% end %>
			</select>
			<div class="widget-buttons buttons-bordered">
				<input class="btn btn-blue btn-xs" name="commit" type="submit" value="选择供应商">
			</div>
			<% end %>
		</div>
	</div>
</div>

<%= simple_form_for(@contract) do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

<%= f.hidden_field :contract_type, value:"采购合同" %>
<div class="row">
	<div class="col-lg-12 col-sm-12 col-xs-12">

		<div class="well invoice-container">
			<div class="row">
				<div class="col-lg-12 col-sm-12 col-xs-12 text-center">
					<h3 class=""> 山东箭波通信设备有限公司 </h3>
					<h3 class=""> 产品采购合同 </h3>
				</div>
			</div>
			<div class="row">
				<div class="col-lg-12 col-sm-12 col-xs-12  text-right">
					<div>
					<span>合同日期: </span><%= f.input_field :contract_date %>
					</div>					
				</div>
			</div>
			<div class="row">
				<div class="col-lg-12 col-sm-12 col-xs-12 text-center">
					<table class="table" >
						<tr>
							<td class="col-md-2 text-right"><span>供方:</span></td>
							<td class="col-md-4 text-left"><%= f.input_field :seller  %> </td>

							<td class="col-md-2 text-right"><span>合同编号:</span></td>
							<td class="col-md-4 text-left"><span><%= f.input_field :contract_code %></span></td>
						</tr>
						<tr>
							<td class="col-md-2 text-right"><span>需方:</span></td>
							<td class="col-md-4 text-left"><span><%= f.input_field :buyer, value: @buyer.name %></span></td>
							<td class="col-md-2 text-right"><span>履行地点:</span></td>
							<td class="col-md-4 text-left"><span><%= f.input_field :jurisdiction, value:"山东省滕州市" %></span></td>
						</tr>
					</table>
				</div>
							
			</div>
			<div class="horizontal-space"></div>
			<div class="row">
				<div class="col-lg-12 col-sm-12 col-xs-12">
					<p>
						为保护供需双方的合法权益，根据《中华人民共和国合同法》，双方在自愿、平等、友好协商的基础上，特订立本合同，双方共同遵照执行：
					</p>
					<p>
						一、产品名称、规格型号、数量、价格、金额
					</p>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-12 col-sm-12 col-xs-12">
					<!-- / end client details section -->
					<table id="invoice" class="table table-bordered table-striped">
						<thead>
							<tr>
								<th class="w-25">产品名称</th>
								<th class="w-25">规格型号</th>
								<th class="w-5">单位</th>
								<th class="w-10">数量</th>
								<th class="w-10">单价（元）</th>
								<th class="w-10">金额</th>

							</tr>
						</thead>
						<tbody>
							<% index = 1 %>
							<%= f.simple_fields_for :contract_items  do |builder| %>
							<%= render "contract_item_fields", :f=> builder, index:index %>
							<% index += 1%>
							<% end %>
						</tbody>
						<tfoot>
							<tr>
								<td>总价</td>
								<td colspan="4"></td>
								<td></td>
							</tr>
							<tr>
								<td colspan="7">备注：
								<input type="text" name=contract[comment] class="form-control">
								</td>
							</tr>
						</tfoot>
					</table>
					<%= link_to_add_association '<i class="fa fa-plus"></i>'.html_safe+'添加产品', f, :contract_items, :data => { "association-insertion-node" => '#invoice tbody', "association-insertion-method" => 'append'}, class: "btn btn-default", render_options:  {locals: { index: index }} %>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-12 col-sm-12 col-xs-12">
					<%= render "purchase_terms_form", :f => f %>
				</div>
			</div>

			<div class="row">
				<div class="col-lg-12 col-sm-12 col-xs-12">
					<table class="table table-bordered">
						<tr>
							<td>
							<ul>
								<li>
									供方单位：
									<%= f.input_field :seller  %>
								</li>
								<li>
									单位地址: <%= f.input_field :seller_address %>

								</li>
								<li>
									委托代理人: <%= f.input_field :seller_agent %>
								</li>
								<li>
									电话: <%= f.input_field :seller_tel %>
								</li>
								<li>
									传真：<%= f.input_field :seller_fax %>
								</li>
								<li>
									开户银行: <%= f.input_field :seller_bank %>
								</li>
								<li>
									账号: <%= f.input_field :seller_bank_account %>
								</li>

							</ul></td>
							<td>
							<ul>
								<li>
									需方单位：<%= f.input_field :buyer, value: @buyer.name %>
								</li>
								<li>
									单位地址: <%= f.input_field :buyer_address, value: @buyer.address %>
								</li>
								<li>
									委托代理人: <%= f.input_field :buyer_agent %>
								</li>
								<li>
									电话: <%= f.input_field :buyer_tel, value:@buyer.tel %>
								</li>
								<li>
									传真：<%= f.input_field :buyer_fax, value:@buyer.fax %>
								</li>
								<li>
									开户银行: <%= f.input_field :buyer_bank, value:@buyer.bank %>
								</li>
								<li>
									账号: <%= f.input_field :buyer_bank_account, value:@buyer.bank_account %>
								</li>
							</ul></td>
						</tr>
					</table>
				</div>
			</div>

			<%= f.button :submit, '提交',class: "btn btn-blue btn-xs", id:"new_contract_submit" %>
		</div>
	</div>
</div>

<% end %>
